package com.netty.demo;

import io.netty.util.internal.SystemPropertyUtil;

import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @Created on 2021/4/13.
 * @Author by zbk
 * @Description:
 */
public class TestScatteringRead {

    public static void main(String[] args) {


        ByteBuffer buffer1 = ByteBuffer.allocate(3);
        ByteBuffer buffer2 = ByteBuffer.allocate(3);
        ByteBuffer buffer3 = ByteBuffer.allocate(5);

        try (FileChannel fileChannel = new RandomAccessFile("data2.txt", "r").getChannel()) {

            fileChannel.read(new ByteBuffer[]{buffer1, buffer2, buffer3});
            buffer1.flip();
            buffer2.flip();
            buffer3.flip();

            System.out.println((char) buffer1.get());
            System.out.println((char) buffer2.get());
            System.out.println((char) buffer3.get());

        }catch (Exception e){

        }

    }


}
